/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyecto.bl;

import java.io.FileInputStream;
import java.util.Properties;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class Emails {




static String sServidorCorreo;
static String sCorreoOrigen;
static String asCorreoDestino;

public static void init (String email, String origen, String servidor) {
    try
    {
        Properties props = new Properties();

       
        sServidorCorreo = servidor;
        sCorreoOrigen = origen;
        asCorreoDestino = email;
    }
    catch( Exception ex )
    {
        
    }

}

public static boolean enviarEmail( String sAsunto, String sTexto )
{
    try
    {
        Properties props = new Properties();
        props.put("mail.smtp.host", sServidorCorreo );
        Session mailSesion = Session.getDefaultInstance(props, null);
        Message msg = new MimeMessage(mailSesion);
        msg.setFrom ( new InternetAddress( sCorreoOrigen ) );
        msg.setSubject ( sAsunto );
        msg.setSentDate ( new java.util.Date() );
        msg.setText ( sTexto );
        InternetAddress address[] = new InternetAddress[1];
        address[0] = new InternetAddress ( asCorreoDestino );
        msg.setRecipients (Message.RecipientType.TO, address);

          
        Transport.send(msg);
      }
      catch( MessagingException e )
      {
          return false ;
      }
   
      return true ;
  }



    
}
